package beanstao.util.response;

import java.lang.reflect.Array;
import java.util.Map;

import org.dom4j.Element;

import beanstao.util.store.domainobject.Domain;
import beanstao.util.store.domainobject.DomainList;
import beanstao.util.table.Table;


public class PDs
{
	@SuppressWarnings("rawtypes")
	public static PD builder(final Object obj)
	{
		if (null == obj)
			return null;
		if (obj instanceof Map)
			return MapData.ME((Map) obj);
		if (obj instanceof Element)
			return ElementData.ME((Element) obj);
		if (obj instanceof Integer)
			return IntegerData.ME(Integer.parseInt(obj.toString()));
		else if (obj instanceof Boolean)
			return BooleanData.ME(Boolean.parseBoolean(obj.toString()));
		else if (obj instanceof String)
			return StringData.ME(obj.toString());
		else if (obj instanceof Table)
			return TableData.ME((Table) obj);
		else if (obj instanceof Object[])
			return ObjectArray.ME((Object[]) obj);
		else if (obj.getClass().isArray())
			return ArrayData.ME((Array) obj);
		else if (obj instanceof Domain)
			return DomainData.ME((Domain) obj);
		else if (obj instanceof DomainList)
			return DomainListData.ME((DomainList) obj);
		return null;
	}
}
